The Let's Play Archive

SHENZHEN I/O

by Quackles

Part 46: Assignment #21: Precision Food Scale

Precision Food Scale



TMI, DAVID.

Oversharing aside, this seems like a potentially nice little project. Let's see what I'm getting into.






Compared to the oracle reader, this project seems super simple. You can do the 'tare' function simply by storing the weight into a register, then taking the difference of what's measured and the 'zero weight' to find what the display should say.

Given that you need -999 to turn the display off, we just set the 'zero weight' to 999. 0 (measured weight) - 999 = -999 = display off.

This should be pretty simple!

[ ~ ]





And here we go! ¥5, 367 average power... it's about as simple as you can possibly get it. If the button is pressed and the saved weight (dat) matches the recorded weight, set it to 999 to turn off. Otherwise, update the saved weight (which will turn it on if it's off).
Whether the button was pressed or not, update the display.

Let's get this ready to send.

[ ~ ~ ]

Oooops. I just caught a bug that would have made the prototype behave pretty embarrassingly. If you placed an item on the scale pan while it was 'off', you would have gotten... OK, let's say the item weighed 10 g. 10 - 999 = -989. Sending -989 to the display makes it show -199. (Sending any number from -199 to -998 will do this.) So the scale doesn't stay off when it's supposed to if you put something on the pan. My simulator's test cases didn't have anything for this!

There's a fix for this problem, and here it is:





The only thing that's different is that the scale script won't update the display every time unit if dat is 999 (i.e. the scale is turned off).
The simulator says this creates a slight increase in power usage to 390 average power, but I have to take issue with the projection this time.

The reasoning is that the simulator's tests mostly focus on the time the scale is on, and not the time it spends off. But really, the scale will probably spend much more time in a day off than on.

So, my old version had:

Power usage in a time unit: 6 (while on / off) / 7 (when button pressed)

   

White lines are on in a time unit that fits the condition. Gray lines are off.

My new version has:

Power usage in a time unit: 7 (on) / 4 (off) / 6-8 (button pressed - 6 to turn off, 8 otherwise)

     

TLDR: The new version uses more power when on, and also when playing with the button - but when it's off, it's only using 2/3 the energy of the first design! If you leave the scale off for an hour, it drains the battery that much more slowly.


Moral of story: simulator tests are great, and also they're not the be-all and end-all. Yes, I know I said I like designing for them when I can a while back. I'd say my new version is better— even so.



David's antics aside, this should be a pretty useful and profitable thing to sell. Another job well done!

I still need to figure out a wedding gift for those two.


P.S: For the My Roommate is a Lamia! fans out there, I just wanna point out that I totally called it about the bass guitar and the main guy joining his best friend's band. That said, I didn't call the twist that his best friend is secretly a succubus...! (Not that he knows yet, but still.) This is definitely shaping up to be a classic-style supernatural love triangle, I'm thinking. I wonder if the second season will be called My Girlfriend Is A Lamia?

...or maybe My Girlfriend Is A Succubus! That'd be interesting.